/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddStudent.java
 *
 * Created on Apr 24, 2013, 6:16:33 PM
 */
package Forms;

import Classes.*;
import java.awt.Color;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author mau
 */
public class AddStudent extends javax.swing.JFrame {
    static MInterface mi;
    static User cUser;
    
    static ArrayList<Curriculum> currList;
    static ArrayList<SchoolYear> syList;
    static ArrayList<SchoolYear> sy;
    static ArrayList<ClassLevel> clevel;
    static ArrayList<ClassLevel> currLevelList;
    ArrayList<SchoolYear> listsy;
    
    static Curriculum curr;
    static SchoolYear syear;
    static Student student;
    
    /** Creates new form AddStudent */
    public AddStudent(User user, MInterface m, Curriculum b) {
        initComponents();
        cUser = user;
        mi = m;
        curr = b;

        try {
            dateLbl.setText(mi.getCurrentDate());
            String currsy = "";
            if (mi.getCurrentDate().compareTo((mi.getEndSy(mi.getCurrentDate()))) > 0) {
                currsy = mi.getToday() + "-" + mi.getNext();
            } else if (mi.getCurrentDate().compareTo((mi.getEndSy(mi.getCurrentDate()))) < 0) {
                currsy = mi.getPast() + "-" + mi.getToday();              
            }
            System.out.println("Currsy " + currsy);
            loadSy();
            loadCurr();
            if(cUser.getType().equals("Administrator")) {
                syCb.setEnabled(true);
            } else {
                 syCb.setEnabled(false);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }    

    public void loadSy() {
        try {
            listsy = (ArrayList<SchoolYear>) mi.getList("getlist-sylist").clone();
                for(int x = 0; x < listsy.size(); x++) {
                    syCb.addItem(listsy.get(x));                    
                }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void loadCurr() {
        try {
            ArrayList<String> listCurr = (ArrayList<String>) mi.getList("getlist-currCb").clone();
            for (int x = 0; x < listCurr.size(); x++) {
                currCb.addItem(listCurr.get(x));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void loadClevel() {
        try {
            clvlCb.removeAllItems();
            origClvl.removeAllItems();
            clevel = (ArrayList<ClassLevel>) mi.getList4("getlist4-level-curr", currCb.getSelectedItem().toString()).clone();
            for (int x = 0; x < clevel.size(); x++) {
                clvlCb.addItem(clevel.get(x).getClassName());
                origClvl.addItem(clevel.get(x).getClassName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
//    public void loadCurrLevelForSy() {
//        try {
//            currCb.removeAllItems();
//            clvlCb.removeAllItems();
//            clevel = (ArrayList<ClassLevel>) mi.getList4("getlist4-level-sy", syCb.getSelectedItem().toString()).clone();
//            for (int x = 0; x < clevel.size(); x++) {
//                currCb.addItem(clevel.get(x).getCurriculum());
//                clvlCb.addItem(clevel.get(x).getClassName());
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bannerL = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jPanel3 = new javax.swing.JPanel();
        IDNoL2 = new javax.swing.JLabel();
        curriculumL2 = new javax.swing.JLabel();
        lastYearLevelL4 = new javax.swing.JLabel();
        clvlCb = new javax.swing.JComboBox();
        picB2 = new javax.swing.JButton();
        fNameL2 = new javax.swing.JLabel();
        fnameFld = new javax.swing.JTextField();
        gNameL2 = new javax.swing.JLabel();
        gnameFld = new javax.swing.JTextField();
        mNameL2 = new javax.swing.JLabel();
        mnameFld = new javax.swing.JTextField();
        SAddressL2 = new javax.swing.JLabel();
        addressFld = new javax.swing.JTextField();
        birthdateL2 = new javax.swing.JLabel();
        birthday = new com.toedter.calendar.JDateChooser();
        birthplaceL2 = new javax.swing.JLabel();
        bplaceFld = new javax.swing.JTextField();
        genderL2 = new javax.swing.JLabel();
        genderCB = new javax.swing.JComboBox();
        cAffiliationL2 = new javax.swing.JLabel();
        churchFld = new javax.swing.JTextField();
        SContactNoL2 = new javax.swing.JLabel();
        cnoFld = new javax.swing.JTextField();
        middleSeparator4 = new javax.swing.JSeparator();
        faNameL2 = new javax.swing.JLabel();
        dadNameFld = new javax.swing.JTextField();
        faOccupationL4 = new javax.swing.JLabel();
        dadOccFld = new javax.swing.JTextField();
        faContactNoL4 = new javax.swing.JLabel();
        dadNoFld = new javax.swing.JTextField();
        moNameL2 = new javax.swing.JLabel();
        momFld = new javax.swing.JTextField();
        faOccupationL5 = new javax.swing.JLabel();
        momOccFld = new javax.swing.JTextField();
        faContactNoL5 = new javax.swing.JLabel();
        momNoFld = new javax.swing.JTextField();
        middleSeparator5 = new javax.swing.JSeparator();
        lastSchoolL2 = new javax.swing.JLabel();
        lastSchoolFld = new javax.swing.JTextField();
        lastYearLevelL5 = new javax.swing.JLabel();
        origClvl = new javax.swing.JComboBox();
        lastSchoolAddressL2 = new javax.swing.JLabel();
        lSchlAddFld = new javax.swing.JTextField();
        GenAveL2 = new javax.swing.JLabel();
        genAveFld = new javax.swing.JTextField();
        bottomSeparator2 = new javax.swing.JSeparator();
        idNumFld = new javax.swing.JTextField();
        dateLbl = new javax.swing.JLabel();
        currCb = new javax.swing.JComboBox();
        syCb = new javax.swing.JComboBox();
        schl2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Add Student");

        bannerL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/banner.jpg"))); // NOI18N
        bannerL.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jSeparator2.setForeground(new java.awt.Color(0, 0, 0));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        IDNoL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        IDNoL2.setText("* I.D. Number:");

        curriculumL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        curriculumL2.setText("Curriculum:");

        lastYearLevelL4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lastYearLevelL4.setText("Admitted To:");

        clvlCb.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        clvlCb.setEditor(null);
        clvlCb.setKeySelectionManager(null);
        clvlCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clvlCbActionPerformed(evt);
            }
        });

        picB2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        picB2.setText("View Picture");
        picB2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                picB2MouseClicked(evt);
            }
        });
        picB2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                picB2ActionPerformed(evt);
            }
        });

        fNameL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        fNameL2.setText("* Family Name:");

        fnameFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        fnameFld.setDisabledTextColor(java.awt.Color.black);
        fnameFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fnameFldKeyTyped(evt);
            }
        });

        gNameL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        gNameL2.setText("* Given Name:");

        gnameFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        gnameFld.setDisabledTextColor(java.awt.Color.black);
        gnameFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                gnameFldKeyTyped(evt);
            }
        });

        mNameL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        mNameL2.setText("* Middle Name:");

        mnameFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        mnameFld.setDisabledTextColor(java.awt.Color.black);
        mnameFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mnameFldKeyTyped(evt);
            }
        });

        SAddressL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        SAddressL2.setText("Address:");

        addressFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        addressFld.setDisabledTextColor(java.awt.Color.black);
        addressFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                addressFldKeyTyped(evt);
            }
        });

        birthdateL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        birthdateL2.setText("* Birthdate:");

        birthday.setDateFormatString("yyyy-MM-dd");
        birthday.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        birthplaceL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        birthplaceL2.setText("Birthplace:");

        bplaceFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        bplaceFld.setDisabledTextColor(java.awt.Color.black);
        bplaceFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                bplaceFldKeyTyped(evt);
            }
        });

        genderL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        genderL2.setText("Gender:");

        genderCB.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        genderCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Male", "Female" }));
        genderCB.setEditor(null);
        genderCB.setKeySelectionManager(null);

        cAffiliationL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        cAffiliationL2.setText("Church Affiliation:");

        churchFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        churchFld.setDisabledTextColor(java.awt.Color.black);
        churchFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                churchFldKeyTyped(evt);
            }
        });

        SContactNoL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        SContactNoL2.setText("Contact No:");

        cnoFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        cnoFld.setDisabledTextColor(java.awt.Color.black);
        cnoFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cnoFldKeyTyped(evt);
            }
        });

        middleSeparator4.setForeground(new java.awt.Color(153, 153, 153));

        faNameL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        faNameL2.setText("* Father's Name:");

        dadNameFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        dadNameFld.setDisabledTextColor(java.awt.Color.black);
        dadNameFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                dadNameFldKeyTyped(evt);
            }
        });

        faOccupationL4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        faOccupationL4.setText("Occupation:");

        dadOccFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        dadOccFld.setDisabledTextColor(java.awt.Color.black);
        dadOccFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                dadOccFldKeyTyped(evt);
            }
        });

        faContactNoL4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        faContactNoL4.setText("* Contact No:");

        dadNoFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        dadNoFld.setDisabledTextColor(java.awt.Color.black);
        dadNoFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                dadNoFldKeyTyped(evt);
            }
        });

        moNameL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        moNameL2.setText("* Mother's Maiden Name:");

        momFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        momFld.setDisabledTextColor(java.awt.Color.black);
        momFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                momFldKeyTyped(evt);
            }
        });

        faOccupationL5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        faOccupationL5.setText("Occupation:");

        momOccFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        momOccFld.setDisabledTextColor(java.awt.Color.black);
        momOccFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                momOccFldKeyTyped(evt);
            }
        });

        faContactNoL5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        faContactNoL5.setText("* Contact No:");

        momNoFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        momNoFld.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        momNoFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                momNoFldKeyTyped(evt);
            }
        });

        middleSeparator5.setForeground(new java.awt.Color(153, 153, 153));

        lastSchoolL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lastSchoolL2.setText("Last School Attended:");

        lastSchoolFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lastSchoolFld.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        lastSchoolFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                lastSchoolFldKeyTyped(evt);
            }
        });

        lastYearLevelL5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lastYearLevelL5.setText("Class Level:");

        origClvl.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        origClvl.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None" }));
        origClvl.setEditor(null);
        origClvl.setEnabled(false);
        origClvl.setKeySelectionManager(null);

        lastSchoolAddressL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lastSchoolAddressL2.setText("Address:");

        lSchlAddFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lSchlAddFld.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        lSchlAddFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                lSchlAddFldKeyTyped(evt);
            }
        });

        GenAveL2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        GenAveL2.setText("Gen.Ave:");

        genAveFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        genAveFld.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        genAveFld.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                genAveFldKeyTyped(evt);
            }
        });

        bottomSeparator2.setForeground(new java.awt.Color(153, 153, 153));

        idNumFld.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        dateLbl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        dateLbl.setText("Date Enrolled");

        currCb.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        currCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                currCbActionPerformed(evt);
            }
        });

        syCb.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        syCb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                syCbActionPerformed(evt);
            }
        });

        schl2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        schl2.setText("School Year:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(lastSchoolAddressL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lSchlAddFld, javax.swing.GroupLayout.PREFERRED_SIZE, 770, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(GenAveL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(genAveFld, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(SAddressL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addressFld, javax.swing.GroupLayout.DEFAULT_SIZE, 1227, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(birthdateL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(birthday, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(birthplaceL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bplaceFld, javax.swing.GroupLayout.DEFAULT_SIZE, 927, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(genderL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(genderCB, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cAffiliationL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(churchFld, javax.swing.GroupLayout.PREFERRED_SIZE, 454, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(SContactNoL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cnoFld, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE))
                    .addComponent(middleSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 1284, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(faNameL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dadNameFld, javax.swing.GroupLayout.PREFERRED_SIZE, 446, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(faOccupationL4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dadOccFld, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(faContactNoL4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(dadNoFld, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(moNameL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(momFld, javax.swing.GroupLayout.PREFERRED_SIZE, 392, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(faOccupationL5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(momOccFld, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(faContactNoL5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(momNoFld, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE))
                    .addComponent(middleSeparator5, javax.swing.GroupLayout.DEFAULT_SIZE, 1284, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(lastSchoolL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lastSchoolFld, javax.swing.GroupLayout.PREFERRED_SIZE, 685, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lastYearLevelL5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(origClvl, 0, 366, Short.MAX_VALUE))
                    .addComponent(bottomSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 1284, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(fNameL2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(fnameFld, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(gNameL2))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(IDNoL2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(idNumFld, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(schl2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(syCb, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addComponent(curriculumL2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(currCb, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(lastYearLevelL4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(clvlCb, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(picB2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(dateLbl))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(gnameFld, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(mNameL2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(mnameFld, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(schl2)
                        .addComponent(syCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(IDNoL2)
                        .addComponent(curriculumL2)
                        .addComponent(idNumFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lastYearLevelL4)
                        .addComponent(clvlCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(picB2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(dateLbl)
                        .addComponent(currCb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fNameL2)
                    .addComponent(fnameFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(gNameL2)
                    .addComponent(gnameFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mNameL2)
                    .addComponent(mnameFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SAddressL2)
                    .addComponent(addressFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(birthdateL2)
                        .addComponent(birthplaceL2)
                        .addComponent(bplaceFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(birthday, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(genderL2)
                    .addComponent(genderCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(churchFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cAffiliationL2)
                    .addComponent(SContactNoL2)
                    .addComponent(cnoFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(middleSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(faContactNoL4)
                        .addComponent(dadNoFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(faOccupationL4)
                        .addComponent(dadOccFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(dadNameFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(faNameL2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(momFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(moNameL2)
                    .addComponent(faOccupationL5)
                    .addComponent(momOccFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(momNoFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(faContactNoL5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(middleSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                    .addComponent(lastSchoolL2)
                    .addComponent(lastSchoolFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lastYearLevelL5)
                    .addComponent(origClvl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lastSchoolAddressL2)
                    .addComponent(lSchlAddFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GenAveL2)
                    .addComponent(genAveFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bottomSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton1.setText("Cancel");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton2.setText("Save");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(bannerL, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(0, 4, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(bannerL)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void clvlCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clvlCbActionPerformed
        if(clvlCb.getSelectedIndex() != 0) {
            origClvl.setSelectedIndex(clvlCb.getSelectedIndex());
        }
}//GEN-LAST:event_clvlCbActionPerformed

    private void picB2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_picB2MouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_picB2MouseClicked

    private void picB2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_picB2ActionPerformed
        //        new ProfilePic(mi, sID).setVisible(true);
}//GEN-LAST:event_picB2ActionPerformed

    private void fnameFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fnameFldKeyTyped
//        // TODO add your handling code here:
//        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(lNameT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@#$%^&*()+=~`|/?.>,<][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
        
    }//GEN-LAST:event_fnameFldKeyTyped

    private void gnameFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_gnameFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(gNameT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@#$%^&*()+=~`|/?.>,<][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
}//GEN-LAST:event_gnameFldKeyTyped

    private void mnameFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mnameFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(lNameT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@#$%^&*()+=~`|/?.>,<][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
}//GEN-LAST:event_mnameFldKeyTyped

    private void addressFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_addressFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(cAddT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?><][}{;:\'\"";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
        
        //        if (!Character.isLetter(c) && c != KeyEvent.VK_SPACE && c != KeyEvent.VK_BACK_SPACE && !Character.isDigit(c)){
        //            evt.consume();
        //            JOptionPane.showMessageDialog (null, "Please enter allowed characters.", "Error", JOptionPane.ERROR_MESSAGE);
        //        }
}//GEN-LAST:event_addressFldKeyTyped

    private void bplaceFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_bplaceFldKeyTyped
        // TODO add your handling code here:
        //        String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(bPlaceT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?><][}{;:\'\"";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
}//GEN-LAST:event_bplaceFldKeyTyped

    private void churchFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_churchFldKeyTyped
        // TODO add your handling code here:
//        String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(cAffT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        if (!Character.isLetter(c) && c != KeyEvent.VK_SPACE && c != KeyEvent.VK_BACK_SPACE){
//            evt.consume();
//            JOptionPane.showMessageDialog(null, "Please enter allowed characters.", "Error", JOptionPane.ERROR_MESSAGE);
//        }
}//GEN-LAST:event_churchFldKeyTyped

    private void cnoFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cnoFldKeyTyped
        // TODO add your handling code here:
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(faCNoT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?.><][}{;:\'\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
    }//GEN-LAST:event_cnoFldKeyTyped

    private void dadNameFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dadNameFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(faNameT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@#$%^&*()+=~`|/?>,<][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
}//GEN-LAST:event_dadNameFldKeyTyped

    private void dadOccFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dadOccFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(faOccuT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|?.><][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
    }//GEN-LAST:event_dadOccFldKeyTyped

    private void dadNoFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dadNoFldKeyTyped
        // TODO add your handling code here:
        //        String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(faCNoT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?.><][}{;:\'\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
        
        
    }//GEN-LAST:event_dadNoFldKeyTyped

    private void momFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_momFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(moNameT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@#$%^&*()+=~`|/?>,<][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH ||  c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
    }//GEN-LAST:event_momFldKeyTyped

    private void momOccFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_momOccFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(moOccuT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|?.><][}{;:\'\"1234567890";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
    }//GEN-LAST:event_momOccFldKeyTyped

    private void momNoFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_momNoFldKeyTyped
        // TODO add your handling code here:
        //        String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(moCNoT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?.><][}{;:\'\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
        
    }//GEN-LAST:event_momNoFldKeyTyped

    private void lastSchoolFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lastSchoolFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(lSchlT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?.>,<][}{;:\'\"";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
    }//GEN-LAST:event_lastSchoolFldKeyTyped

    private void lSchlAddFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lSchlAddFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(lSchlAddT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        String s = "!@$%^&*()+=~`|/?><][}{;:\'\"";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }
    }//GEN-LAST:event_lSchlAddFldKeyTyped

    private void genAveFldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_genAveFldKeyTyped
        // TODO add your handling code here:
        //String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//        
//        if(c == KeyEvent.VK_SPACE) {
//            if(genAveT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog(null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//        }
//        
//        //char c = evt.getKeyChar();
//        
//        
//        String s = "!@$%^&*()+=~`|/?> <][}{;:\'\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
//        
//        //char c = evt.getKeyChar();
//        if (s.contains(c + "") || c == KeyEvent.VK_BACK_SLASH || c == KeyEvent.VK_ENTER) {
//            if(c == KeyEvent.VK_ENTER) {
//                //jButton7ActionPerformed(null);
//                saveBMouseClicked(null);
//            } else {
//                evt.consume();
//            }
//        }        
        
    }//GEN-LAST:event_genAveFldKeyTyped

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        this.hide();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
            String bday = ((JTextField)birthday.getDateEditor().getUiComponent()).getText();
            String gender = genderCB.getSelectedItem().toString();
//            String curr = currCb.getSelectedItem().toString();
//            String sy = syCb.getSelectedItem().toString();
//            String clvl = clvlCb.getSelectedItem().toString();
                        
            String id = idNumFld.getText();
            String fname = fnameFld.getText();
            String gname = gnameFld.getText();
            String mname = mnameFld.getText();
            String address = addressFld.getText();
            String bplace = bplaceFld.getText();
            String church = churchFld.getText();
            String num = cnoFld.getText();
            String dad = dadNameFld.getText();
            String dadWork = dadOccFld.getText();
            String dadNum = dadNoFld.getText();
            String mom = momFld.getText();
            String momWork = momOccFld.getText();
            String momNum = momNoFld.getText();
            String lastSchool = lastSchoolFld.getText();
            String lastAdd = lSchlAddFld.getText();
            String ave = genAveFld.getText();
            
            String status = "Undergraduate";                     
                      
            boolean add = false;
            if (!add) {
                if (id.isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Enter a students ID Number", "Error", JOptionPane.ERROR_MESSAGE);
                    IDNoL2.setForeground(Color.red);
                } else if (fname.isEmpty() || gname.isEmpty() || mname.isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Enter the student's name", "Error", JOptionPane.ERROR_MESSAGE);
                    fNameL2.setForeground(Color.red);
                    gNameL2.setForeground(Color.red);
                    mNameL2.setForeground(Color.red);
                } else {
                    student = new Student(check(id), check(fname), check(gname), check(mname), 
                    check(address), check(bday), check(bplace), check(gender), check(church), check(num), 
                    check(dad), check(dadWork), check(dadNum), check(mom), check(momWork), check(momNum), 
                    check(lastSchool), check(lastAdd), checkGenAve(), clevel.get(clvlCb.getSelectedIndex()).getClassID(), 
                    sy.get(syCb.getSelectedIndex()).getSyName(), currList.get(currCb.getSelectedIndex()).getCurrID());  
                    
                    add = mi.add("add-student", student, "", cUser);
                    JOptionPane.showMessageDialog(null, "Student Successfully Added.", "Message", JOptionPane.INFORMATION_MESSAGE);
                }
            } else if (add) {
                JOptionPane.showMessageDialog(null, "Student already exist", "Error", JOptionPane.ERROR_MESSAGE);
            }            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void currCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_currCbActionPerformed
       loadClevel();       
    }//GEN-LAST:event_currCbActionPerformed

    private void syCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_syCbActionPerformed
//        loadCurrLevelForSy();
    }//GEN-LAST:event_syCbActionPerformed
    
    public String check(String a) {
        if(a.equals("")) {
            return "N/A";
        }
        return a;
    }
    
    public String checkGenAve() {
        if(genAveFld.getText().equals("")) {
            return "0";
        }
        return genAveFld.getText();
    }
    
    public String checkStatus() {
        String status = "Gradute";
        if (!lastSchoolFld.getText().toLowerCase().contains("MEAB") || !lastSchoolFld.getText().toLowerCase().contains("Math Excellence Academy") || !lastSchoolFld.getText().toLowerCase().contains("Math Excellence Academy of Binalonan")) {
            status = "Transferee";
        } else {
            status = "Undergraduate";
        }
        return status;
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AddStudent(cUser, mi, curr).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel GenAveL2;
    private javax.swing.JLabel IDNoL2;
    private javax.swing.JLabel SAddressL2;
    private javax.swing.JLabel SContactNoL2;
    private javax.swing.JTextField addressFld;
    private javax.swing.JLabel bannerL;
    private javax.swing.JLabel birthdateL2;
    private com.toedter.calendar.JDateChooser birthday;
    private javax.swing.JLabel birthplaceL2;
    private javax.swing.JSeparator bottomSeparator2;
    private javax.swing.JTextField bplaceFld;
    private javax.swing.JLabel cAffiliationL2;
    private javax.swing.JTextField churchFld;
    private javax.swing.JComboBox clvlCb;
    private javax.swing.JTextField cnoFld;
    private javax.swing.JComboBox currCb;
    private javax.swing.JLabel curriculumL2;
    private javax.swing.JTextField dadNameFld;
    private javax.swing.JTextField dadNoFld;
    private javax.swing.JTextField dadOccFld;
    private javax.swing.JLabel dateLbl;
    private javax.swing.JLabel fNameL2;
    private javax.swing.JLabel faContactNoL4;
    private javax.swing.JLabel faContactNoL5;
    private javax.swing.JLabel faNameL2;
    private javax.swing.JLabel faOccupationL4;
    private javax.swing.JLabel faOccupationL5;
    private javax.swing.JTextField fnameFld;
    private javax.swing.JLabel gNameL2;
    private javax.swing.JTextField genAveFld;
    private javax.swing.JComboBox genderCB;
    private javax.swing.JLabel genderL2;
    private javax.swing.JTextField gnameFld;
    private javax.swing.JTextField idNumFld;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField lSchlAddFld;
    private javax.swing.JLabel lastSchoolAddressL2;
    private javax.swing.JTextField lastSchoolFld;
    private javax.swing.JLabel lastSchoolL2;
    private javax.swing.JLabel lastYearLevelL4;
    private javax.swing.JLabel lastYearLevelL5;
    private javax.swing.JLabel mNameL2;
    private javax.swing.JSeparator middleSeparator4;
    private javax.swing.JSeparator middleSeparator5;
    private javax.swing.JTextField mnameFld;
    private javax.swing.JLabel moNameL2;
    private javax.swing.JTextField momFld;
    private javax.swing.JTextField momNoFld;
    private javax.swing.JTextField momOccFld;
    private javax.swing.JComboBox origClvl;
    private javax.swing.JButton picB2;
    private javax.swing.JLabel schl2;
    private javax.swing.JComboBox syCb;
    // End of variables declaration//GEN-END:variables
}
